//
//  PaySucceedViewController.m
//  Consume100
//
//  Created by eliot on 16/3/28.
//  Copyright © 2016年 aleven. All rights reserved.
//

#import "PaySucceedViewController.h"
#import "ConsumeDetailViewController.h"
@interface PaySucceedViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (weak, nonatomic) IBOutlet UIView *btnBGV;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconLeft;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bmyDetailBtnW;

@property (weak, nonatomic) IBOutlet UIButton *bmyDetailBtn;

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableViewH;

@end

@implementation PaySucceedViewController

+(PaySucceedViewController*)CreatPaySucceedViewController{
    
    UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    PaySucceedViewController *PaySucceedViewController=[story instantiateViewControllerWithIdentifier:@"PaySucceedViewController"];
    return PaySucceedViewController;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.iconLeft.constant = Width / 2 - 55;
    self.bmyDetailBtnW.constant = 120 / 320.0 *Width;
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.tableView.backgroundColor = [UIColor colorWithRed:237/255.0 green:237/255.0 blue:237/255.0 alpha:1];
    self.btnBGV.backgroundColor = [UIColor colorWithRed:237/255.0 green:237/255.0 blue:237/255.0 alpha:1];
    self.title = @"支付订单";
    if (self.isFromFirstPage) {
        self.tableViewH.constant = 132;
    }else {
        self.tableViewH.constant = 176;
        [self.bmyDetailBtn setTitle:@"返回" forState:UIControlStateNormal];
    }
    /** 设置导航啦样式*/
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
    self.navigationController.navigationBar.translucent = NO;
    self.bmyDetailBtn.layer.cornerRadius = 8;
    self.bmyDetailBtn.layer.masksToBounds = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/** 点击我的订单*/
- (IBAction)clickbmyDetailBtnclick:(id)sender {
    

    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (self.isFromFirstPage) {
        return 3;
    }else {
        return 4;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (self.isFromFirstPage) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"lastCell"];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"lastCell"];
        }
        if (indexPath.row == 0) {
            cell.textLabel.text = @"交易单号";
            cell.detailTextLabel.text = @"1234567890123456789";
        }else if (indexPath.row == 1) {
            cell.textLabel.text = @"交易时间";
            cell.detailTextLabel.text = @"3016-03-20 14:00:30";
        }else {
            cell.textLabel.text = @"支付方式";
            cell.detailTextLabel.text = @"微信支付";
        }
        return cell;
    }else {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"lastCell"];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"lastCell"];
        }
        if (indexPath.row == 0){
            cell.textLabel.text = @"充值金币";
            cell.detailTextLabel.text = @"200个";
        
        }else if (indexPath.row == 1) {
            cell.textLabel.text = @"交易单号";
            cell.detailTextLabel.text = @"1234567890123456789";
        }else if (indexPath.row == 2) {
            cell.textLabel.text = @"交易时间";
            cell.detailTextLabel.text = @"3016-03-20 14:00:30";
        }else {
            cell.textLabel.text = @"支付方式";
            cell.detailTextLabel.text = @"微信支付";
        }
        return cell;
    }
    
}


/** 点击  我的订单*/
- (IBAction)clickMyDetail:(id)sender {
    if (self.isFromFirstPage) {
        ConsumeDetailViewController *vc = [ConsumeDetailViewController CreatConsumeDetailViewController];
        [self creatNav:vc];

    }
}



//创建模态导航控制器
-(void)creatNav:(UIViewController *)view{
    
    UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:view];
    nav.navigationBar.barTintColor = [UIColor colorWithRed:254/255.0 green:154/255.0 blue:37/255.0 alpha:1];
    view.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_back"] style:UIBarButtonItemStylePlain target:self action:@selector(dismiss)];
    [self presentViewController:nav animated:YES completion:nil];
}

- (void)dismiss {
    [self dismissViewControllerAnimated:YES completion:nil];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
